<template>
	<div>
		<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
		<div style="padding: 20px;">
			<!--班级得分(改完字段)-->
			<!--<div style="margin:5px 0px 0px 0px;background-color: #f5f5f5;padding: 20px;">
				<Row >
			        <Col span="24" style="text-align: left;">
						<span style="font-size: 18px;color: #1a1a1a;font-weight: 540;">评价名称：{{excelname}}</span>
					</Col>
				</Row>
				<Row style="margin:15px 0px 0px 0px;color: #666666;">
			        <Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">年级：{{gradeName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">基数：{{baseExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">本次：{{thisExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">时间：{{createTime}}</span>
					</Col>
				</Row>
			</div>-->
			
			<Row style="text-align: left;margin-top: 20px;margin-left:-20px ;">
				<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
				<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">班级得分</span>
			</Row >
			<v-table :min-height='500' :is-loading="loadingShow1" is-horizontal-resize is-vertical-resize  row-click-color="#3dd9cc29"  is-horizontal-resize style="width:100%;margin-top:20px;"  :columns="columns1" :table-data="tableData1" ></v-table>
			
			
			
			
			
			<Row style="text-align: left;margin-top: 20px;margin-left:-20px ;">
				<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
				<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">各科目详细得分</span>
			</Row >
			<Row >
		        <Col span="24" style="text-align: left;margin-top:20px;">
		        	<span>科目筛选：</span>
		        	<RadioGroup  v-model="subjectselect" type="button" @on-change="changeselect">
		        		<Radio v-for="item in subjectlist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		        <Spin size="large" fix v-if="subjectlistshow"></Spin>
		    </Row>
			<Row style="margin-top:20px">
		        <Col span="24" style="text-align: right;margin-bottom:10px;">
		        	<!--<Button style="background-color: #4496fc;" size="small" :loading="loading" @click="exportexl">
		        		<span v-if="!loading"><img style="width: 20px;margin-top: 2px;" src="../../../../../../static/img/export.png" alt="" /></span>
				        <span v-else>加载中</span>
		        	</Button>-->
		        </Col>
		    </Row>
			<v-table :min-height='500' v-if="height" :is-loading="loadingShow" is-horizontal-resize is-vertical-resize  row-click-color="#3dd9cc29"  is-horizontal-resize style="width:100%"  :columns="columns" :table-data="tableData" ></v-table>
			<!--<v-table :min-height='500' v-if="mid" :is-loading="loadingShow" is-horizontal-resize is-vertical-resize row-click-color="#3dd9cc29"     :columns="midcolumns" style="width:100%" :table-data="midtableData" ></v-table>-->
		</div>
	</div>	
</template>

<script>
	import { getsessionstorage } from '@/components/js/Localstorage'
	import api from "@/components/js/Apidomain.js"
	
	export default{
		data(){
			return{
				subjectselect:"",				//选择的科目
				subjectlist: [],
				
				subjectlistshow:false,			//科目选择列表的加载中显示隐藏
				
//				excelname:"",			//查询的名字
//				gradeName:"",			//查询的年级
//				baseExamName:"",		//查询的基数考试名字
//				thisExamName:"",		//查询的本次考试名字
//				createTime:"",			//查询的评价时间			
				
				loadingShow:false,				//表格获取的加载中显示隐藏
				loadingShow1:false,				//表格获取的加载中显示隐藏
				loading: false,				//下载模板按钮上的加载中显示隐藏
				
				height:true,					//高中
//				mid:true,						//初中
				
				
				columns: [
					{field: 'classesNo', title:'班级', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'averageGoal', title:'平均', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'passRateGoal', title: '及格', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'excellentRateGoal', title: '优秀', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'backGoal', title: '巩固', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'forewardGoal', title: '提升', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'verticalGoal', title: '纵向', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'results', title: '得分', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                ],
                tableData: [],
                
                columns1: [
					{field: 'classesNo', title:'班级', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'sumResults', title:'各科得分总和', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'classesResultsNo', title: '年段排名', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                    {field: 'classesResults', title: '班级得分', width: 95, titleAlign: 'center',columnAlign:'center',isResize:true},
                ],
                tableData1: [],
				
				
				
			}
		},
		created(){
			
//			this.excelname = getsessionstorage('excelname')
//			this.gradeName = getsessionstorage('gradeName')
//			this.baseExamName = getsessionstorage('baseExamName')
//			this.thisExamName = getsessionstorage('thisExamName')
//			this.createTime = getsessionstorage('createTime')
			this.getsubjectlist();
//			this.gettablelist();
		},
		mounted(){
//			//console.log('mounted')
		},
		computed: {
			
		},
		methods:{
			getsubjectlist:function(){
           		this.subjectlistshow = true;
           		let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId')
				let sessiongradeid = getsessionstorage('gradeId')
           		
           		var senddata = {
					 	"performId":sessionperformId,//绩效Id
						"roleId":sessionroleid,//角色Id
						"gradeId":sessiongradeid//年级Id
					}
           		
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaPerformance/getSubjectByGrade';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						
//						////console.log(response.data.data)
						self.subjectlist = response.data.data
						if(self.subjectlist.length != 0){
							self.subjectselect = self.subjectlist[0].value;
							self.gettablelist();
						}
						
						self.subjectlistshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            		self.subjectlistshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00156',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
           	},
			changeselect:function(){
				this.gettablelist();
			},
			gettablelist:function(){
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId')
				let sessiongradeid = getsessionstorage('gradeId')
				if(sessionroleid && sessionperformId && sessiongradeid){
					
					var senddata = {
						"subject":this.subjectselect, //科目
					 	"performId":sessionperformId,//绩效Id
						"roleId":sessionroleid,//角色Id
						"gradeId":sessiongradeid//年级Id
					}
					
					this.loadingShow = true;
					this.loadingShow1 = true;
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaClassesResults/getClassesResultsNew';
	            	this.$http.post(url,senddata).then(function(response) {
						if(response.data.success == true){
							
//		            		console.log(response.data.data)
							self.tableData1 = response.data.data.classesTotalResultss
		            		self.tableData = response.data.data.classesResultss;
//		            		
							self.loadingShow = false;
							self.loadingShow1 = false;
			            }else if(response.data.success == false){
			            		self.loadingShow = false;
			            		self.loadingShow1 = false;
			            		self.$Message.error({
									content: response.data.msg,
									duration: 10,
									closable: true
								});	
			            	}
			            })
						.catch(function(error) {
							self.loadingShow = false;
							self.loadingShow1 = false;
							self.$Message.error({
								content: '系统发生错误：错误码00139',
								duration: 10,
								closable: true
							});
						});
				}else{
					self.$Message.error({
							content: '系统发生错误：错误码00140',
							duration: 10,
							closable: true
						});
				}
			},
//			gettablelist1:function(){
//				let sessionroleid = getsessionstorage('roleid');
//				let sessionperformId = getsessionstorage('performId')
//				let sessiongradeid = getsessionstorage('gradeId')
//				if(sessionroleid && sessionperformId && sessiongradeid){
//					
//					var senddata = {
//					 	"performId":sessionperformId,//绩效Id
//						"roleId":sessionroleid,//角色Id
//						"gradeId":sessiongradeid//年级Id
//					}
//					
//					this.loadingShow1 = true;
//					var self = this;
//	            	let url = api.apidomain+'/tqes/web/quaClassesResults/getClassesResultsNew';
//	            	this.$http.post(url,senddata).then(function(response) {
//						if(response.data.success == true){
////		            		console.log(response.data.data)
//		            		self.tableData1 = response.data.data.classesResultss;
//							self.loadingShow1 = false;
//			            }else if(response.data.success == false){
//			            		self.loadingShow1 = false;
//			            		self.$Message.error({
//									content: response.data.msg,
//									duration: 10,
//									closable: true
//								});	
//			            	}
//			            })
//						.catch(function(error) {
//							self.loadingShow1 = false;
//							self.$Message.error({
//								content: '系统发生错误：错误码00312',
//								duration: 10,
//								closable: true
//							});
//						});
//				}else{
//					self.$Message.error({
//							content: '系统发生错误：错误码00313',
//							duration: 10,
//							closable: true
//						});
//				}
//			},
			exportexl:function(){
				
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				let sessiongradeid = getsessionstorage('gradeId');
				if(sessionroleid && sessionperformId){
					this.loading = true;
				
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaClassesResults/exportExcelDto/'+sessionperformId+'/'+sessionroleid+'/'+sessiongradeid;
	            	this.$http.post(url).then(function(response) {
						if(response.data.success == true){
	//						////console.log(response.data.data)
							window.location.href = response.data.data;
							self.loading = false;
		            }else if(response.data.success == false){
		            		self.loading = false;
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
		            	}
		            	
					})
					.catch(function(error) {
						self.loading = false;
						self.$Message.error({
							content: '系统发生错误：错误码00141',
							duration: 10,
							closable: true
						});
					});
				}
			} 
			
//			saveAs:function(obj, fileName) {//当然可以自定义简单的下载文件实现方式 
//	            var tmpa = document.createElement("a");
//	            tmpa.download = fileName || "下载";
//	            tmpa.href = URL.createObjectURL(obj); //绑定a标签
//	            //console.log(tmpa.href);
//	            tmpa.click(); //模拟点击实现下载
//	            setTimeout(function () { //延时释放
//	                URL.revokeObjectURL(obj); //用URL.revokeObjectURL()来释放这个object URL
//	            }, 100);
//	        }
		}
	}
</script>

<style>
</style>